<template>
	<view class="template-myblog tn-safe-area-inset-bottom">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed>
			专家主页
		</tn-nav-bar>
		<view class="top-backgroup">
			<!-- <image src='../../static/my-vip.jpg' mode='widthFix' class='backgroud-image'>
			</image> -->
		</view>
		<view class="about__wrap" style="margin-top: -240rpx;">
			<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom">
				<view class="justify-content-item" style="width: 100%;">
					<view class="tn-flex tn-flex-col-center tn-flex-row-left">
						<!-- 图标logo -->
						<view class="logo-pic tn-shadow">
							<view class="logo-image">
								<view class="tn-shadow-blur" style="width: 100rpx;height: 100rpx;">
									<image :src="expert.avatar" style="width: 100rpx;height: 100rpx;"></image>
								</view>
								<!-- <view class="tn-icon-logo-tuniao" style="font-size: 100rpx;color: #01BEFF;padding: 16rpx 0;"></view> -->
							</view>
						</view>
						<view class="tn-padding-right tn-color-white">
							<view class="tn-padding-right tn-padding-left-sm tn-text-xl tn-text-bold">
								{{expert.name}}<text
									class="tn-color-orange--dark tn-text-bold tn-padding-left-sm">{{expert.rankName}}</text>
							</view>
							<view class="tn-padding-right tn-padding-top-xs tn-padding-left-sm tn-text-ellipsis">
								<text class="">{{expert.hospital}}</text>
							</view>
							<view class="tn-padding-right tn-padding-top-xs tn-padding-left-sm tn-text-ellipsis" style="color: #e6e6e6;">
								<text class="">{{expert.department}}</text>
							</view>
						</view>

					</view>
					<view class="tn-flex tn-flex-col-center tn-flex-row-right" style="margin-top: 20rpx;">
						<view style="margin-right: 40rpx;color:#E4E9EC;">粉丝数：{{expert.fansCount}}</view>
						<tn-button backgroundColor="#f93b31" fontColor="#ffffff" v-if="expert.userExpertStatus == '0'"
							@click="followExpertFunction">关 注</tn-button>
						<tn-button backgroundColor="#aaaaaa" fontColor="#ffffff" v-else
							@click="cancelFollowExpertFunction">取消关注</tn-button>
					</view>

				</view>
			</view>
			<view style="margin-top: 30rpx;">
				<tn-tabs :list="tabList" :isScroll="false" :current="current" name="tabName" @change="changeTab">
				</tn-tabs>
			</view>
			<block v-if="current==0">
				<view class="title-name" style="margin-top: 20rpx;"><text class="tn-icon-medical" style="margin-right: 10rpx;color: #0FD850; "></text>临床科室</view>
				<view class="title-name" style="font-weight: normal;">{{expert.department||'暂无'}}</view>
				<view class="title-name"><text class="tn-icon-trusty" style="margin-right: 10rpx;color: #007AFF;"></text>专业职称</view>
				<view class="title-name" style="font-weight: normal;">{{expert.rankName||'暂无'}}</view>
				<view class="title-name"><text class="tn-icon-charts-column" style="margin-right: 10rpx;color: #CCA220;"></text>临床领域</view>
				<view class="title-name" style="font-weight: normal;">{{expert.speciality||'暂无'}}</view>
				<view class="title-name"><text class="tn-icon-my-love" style="margin-right: 10rpx;color: #007AFF;"></text>医生简介</view>
				<rich-text class="text" :nodes="expert.notes"></rich-text>
				<view class="title-name"><text class="tn-icon-job" style="margin-right: 10rpx;color: #0FD850;"></text>执业经历</view>
				<rich-text class="text" :nodes="expert.exps"></rich-text>
				<view class="title-name"><text class="tn-icon-trophy" style="margin-right: 10rpx;color:#CCA220;"></text>学术成就</view>
				<rich-text class="text" :nodes="expert.achiev"></rich-text>
			</block>
			<block v-else>
				<view class="" style="padding-top: 20rpx;" v-if="liveData.length>0">
					<view class="tn-flex tn-flex-row-between tn-padding-top-xl">
						<view class="justify-content-item tn-text-bold tn-text-lg">
							<text class="">直播列表</text>
						</view>
						<view class="justify-content-item tn-text-df" @click="moreLive">
							<text class="tn-padding-xs">全部</text>
							<text class="tn-icon-right"></text>
						</view>
					</view>
				</view>
				<!-- 直播预告 start-->
				<preview-list :dataList="liveData" @refreshLive="getlive"></preview-list>
				<view class="tn-flex tn-flex-row-between tn-padding-top-xl">
					<view class="justify-content-item tn-text-bold tn-text-lg">
						<text class="">微课列表</text>
					</view>
					<!-- <view class="justify-content-item tn-text-df">
						<text class="tn-padding-xs">全部</text>
						<text class="tn-icon-right"></text>
					</view> -->
				</view>
				<!-- 更多信息-->
				<view class="about-shadow tn-margin-top-xl  tn-color-black tn-bg-white"
					style="color: #0E122A;text-shadow:#0E122A 0rpx 0rpx 0rpx;">
					<!-- 方式12 start-->
					<content-list ref="contentList" :dataList='content'></content-list>
					<!-- 方式12 end-->
				</view>
				<tn-load-more status="nomore" v-if="content.length === 0"></tn-load-more>
			</block>

		</view>

	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import {
		getExpertInfo,
		getLiveList,
		getAllLiveList,
		getContentsByTag,
		followExpert,
		cancelFollowExpert
	} from '@/util/index.js'
	export default {
		name: 'TemplateMyblog',
		mixins: [template_page_mixin],
		data() {
			return {
				expert: {},
				liveData: [],
				content: [],
				id: '',
				tabList: [{
					tabName: '专家介绍'
				}, {
					tabName: '专家讲座'
				}],
				current: 0,
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getData()
			this.getlive()
			this.getContent()
		},
		methods: {
			changeTab(e) {
				this.current = e
			},
			processRichText(htmlContent) {
				// 处理图片样式
				let processedHtml = htmlContent.replace(/<span([^>]*)>/gi, (match, attributes) => {
					// 添加内联样式
					return `<span style="font-size: 30rpx !important;line-height: 50rpx!important;">`;
				});
				return processedHtml
			},
			getData() {
				getExpertInfo({
					id: this.id
				}).then((res) => {
					if(res.notes){
						res.notes =this.processRichText(res.notes)
					}
					if(res.exps){
						res.exps =this.processRichText(res.exps)
					}
					if(res.achiev){
						res.achiev =this.processRichText(res.achiev)
					}
					this.expert = res
				})
			},
			moreLive(){
				uni.navigateTo({
					url: `/articleVideo/live/live?expertId=${this.id}`
				})
			},
			//获取直播列表
			getlive() {
				getAllLiveList({
					page: 1,
					limit: 6,
					expertId: this.id
				}).then((res) => {
					this.liveData = res.list
				})
			},
			//获取内容
			getContent() {
				getContentsByTag({
					page: 1,
					limit: 100,
					expertId: this.id
				}).then((res) => {
					this.content = res.list
				})
			},
			//关注医生
			followExpertFunction() {
				followExpert({
					expertId: this.id
				}).then((res) => {
					this.expert.fansCount++
					this.expert.userExpertStatus = '1'
				})
			},
			cancelFollowExpertFunction() {
				cancelFollowExpert({
					expertId: this.id
				}).then((res) => {
					this.expert.fansCount--
					this.expert.userExpertStatus = '0'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/templatePage/custom_nav_bar.scss';

	.template-myblog {}

	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			margin: auto 5rpx;
			font-size: 40rpx;
			margin-right: 10rpx;
			flex-basis: 5%;
			width: 100rpx;
			position: absolute;
		}
	}

	/* 自定义导航栏内容 end */

	/* 顶部背景图 start */
	.top-backgroup {
		height: 450rpx;
		z-index: -1;
		background-color: #6c909e;

		.backgroud-image {
			width: 100%;
			height: 480rpx;
			// z-index: -1;
		}
	}

	/* 顶部背景图 end */

	/* 标题 start */
	.nav_title {
		-webkit-background-clip: text;
		color: #0E122A;


		&--wrap {
			position: relative;
			display: flex;
			height: 120rpx;
			align-items: center;
			justify-content: center;
			font-weight: bold;
			background-image: url(https://resource.tuniaokj.com/images/title_bg/title44.png);
			background-size: cover;
		}
	}

	/* 标题 end */

	/* 用户头像 start */
	.logo-image {
		width: 100rpx;
		height: 100rpx;
		position: relative;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 50%;
		overflow: hidden;
		background-color: #FFFFFF;
	}

	/* 页面 start*/
	.about-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.about {

		&__wrap {
			position: relative;
			z-index: 1;
			margin: 20rpx 30rpx;
			margin-top: -230rpx;
		}
	}

	/* 页面 end*/

	/* 图标容器15 start */
	.icon15 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 15rpx;
				height: 15rpx;
				font-size: 66rpx;
				border-radius: 50%;
				margin-bottom: 38rpx;
				position: relative;
				text-shadow: #0E122A 0rpx 0rpx 0rpx;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg6.png);

				}
			}
		}
	}

	/* 图标容器1 start */
	.icon1 {
		&__item {
			// width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 40rpx;
				height: 40rpx;
				font-size: 28rpx;
				border-radius: 50%;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg.png);
				}
			}
		}
	}

	/* 图标容器1 end */

	/* 底部tabbar start*/
	.footerfixed {
		position: fixed;
		width: 100%;
		bottom: 0;
		z-index: 999;
		background-color: #FFFFFF;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.tabbar {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		justify-content: space-between;
		padding: 0;
		height: calc(110rpx + env(safe-area-inset-bottom) / 2);
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
	}

	.tabbar .action {
		font-size: 22rpx;
		position: relative;
		flex: 1;
		text-align: center;
		padding: 0;
		display: block;
		height: auto;
		line-height: 1;
		margin: 0;
		overflow: initial;
	}

	.bar-center {
		animation: suspension 3s ease-in-out infinite;
	}

	@keyframes suspension {

		0%,
		100% {
			transform: translateY(0);
		}

		50% {
			transform: translateY(-0.8rem);
		}
	}

	.tabbar .action .bar-icon {
		width: 100rpx;
		position: relative;
		display: block;
		height: auto;
		margin: 0 auto 10rpx;
		text-align: center;
		font-size: 42rpx;
		// line-height: 50rpx;
	}

	.tabbar .action .bar-icon image {
		width: 50rpx;
		height: 50rpx;
		display: inline-block;
	}

	.tabbar .action .bar-circle {
		position: relative;
		display: block;
		margin: 0rpx auto 0rpx;
		text-align: center;
		font-size: 52rpx;
		line-height: 90rpx;
		// background-color: #01BEFF;
		width: 100rpx !important;
		height: 100rpx !important;
		overflow: hidden;
		// border-radius: 50%;
		// box-shadow: 0px 10px 30px rgba(70,23,129, 0.12),
		//   0px -8px 40px rgba(255, 255, 255, 1),
		//   inset 0px -10px 10px rgba(70,23,129, 0.05),
		//   inset 0px 10px 20px rgba(255, 255, 255, 1);
		// box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(1, 190, 255, 0.5);
	}

	.tabbar .action .bar-circle image {
		width: 100rpx;
		height: 100rpx;
		display: inline-block;
		margin: 0rpx auto 0rpx;
	}

	/* 流星+悬浮 */
	.nav-index-button {
		animation: suspension 3s ease-in-out infinite;
		z-index: 999999;


		&__content {
			position: absolute;
			width: 100rpx;
			height: 100rpx;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;
				transform: scale(0.85);

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					// background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg6.png);
				}
			}
		}

		&__meteor {
			position: absolute;
			top: 50%;
			left: 50%;
			width: 100rpx;
			height: 100rpx;
			transform-style: preserve-3d;
			transform: translate(-50%, -50%) rotateY(75deg) rotateZ(10deg);

			&__wrapper {
				width: 100rpx;
				height: 100rpx;
				transform-style: preserve-3d;
				animation: spin 20s linear infinite;
			}

			&__item {
				position: absolute;
				width: 100rpx;
				height: 100rpx;
				border-radius: 1000rpx;
				left: 0;
				top: 0;

				&--pic {
					display: block;
					width: 100%;
					height: 100%;
					background: url(https://resource.tuniaokj.com/images/cool_bg_image/arc1.png) no-repeat center center;
					background-size: 100% 100%;
					animation: arc 4s linear infinite;
				}
			}
		}
	}


	@keyframes suspension {

		0%,
		100% {
			transform: translateY(0);
		}

		50% {
			transform: translateY(-0.6rem);
		}
	}

	@keyframes spin {
		0% {
			transform: rotateX(0deg);
		}

		100% {
			transform: rotateX(-360deg);
		}
	}

	@keyframes arc {
		to {
			transform: rotate(360deg);
		}
	}


	/* 图标容器12 start */
	.icon12 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				// border-radius: 50%;
				margin-bottom: 0rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					// background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg.png);


				}
			}
		}
	}

	/* 图标容器11 start */
	.icon11 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg.png);
				}
			}
		}
	}

	/**/
	@keyframes t {

		0%,
		10%,
		80%,
		100% {
			top: -30px;
		}

		20% {
			top: 0px;
		}

		30% {
			top: -20px;
		}

		40% {
			top: -0px;
		}

		50% {
			top: -25px;
		}

		70% {
			top: 0px;
		}
	}

	@keyframes b {

		0%,
		10%,
		80%,
		100% {
			bottom: -30px;
		}

		20% {
			bottom: 0px;
		}

		30% {
			bottom: -20px;
		}

		40% {
			bottom: -0px;
		}

		50% {
			bottom: -25px;
		}

		70% {
			bottom: 0px;
		}
	}

	@keyframes mouth {

		0%,
		10%,
		100% {
			width: 100%;
			height: 0%;
		}

		15% {
			width: 90%;
			height: 30%;
		}

		20% {
			width: 50%;
			height: 70%;
		}

		25% {
			width: 70%;
			height: 70%;
		}

		30% {
			width: 80%;
			height: 60%;
		}

		35% {
			width: 60%;
			height: 70%;
		}

		40% {
			width: 55%;
			height: 75%;
		}

		45% {
			width: 50%;
			height: 90%;
		}

		50% {
			width: 40%;
			height: 70%;
		}

		55% {
			width: 70%;
			height: 95%;
		}

		60% {
			width: 40%;
			height: 50%;
		}

		65% {
			width: 100%;
			height: 60%;
		}

		70% {
			width: 100%;
			height: 70%;
		}

		75% {
			width: 90%;
			height: 70%;
		}

		80% {
			width: 50%;
			height: 70%;
		}

		85% {
			width: 90%;
			height: 50%;
		}

		85% {
			width: 40%;
			height: 70%;
		}

		90% {
			width: 90%;
			height: 30%;
		}

		95% {
			width: 100%;
			height: 10%;
		}
	}

	@keyframes tongue {

		0%,
		20%,
		100% {
			bottom: -80px;
		}

		30%,
		90% {
			bottom: -40px;
		}

		40% {
			bottom: -45px;
		}

		50% {
			bottom: -50px;
		}

		70% {
			bottom: -80px;
		}

		90% {
			bottom: -40px;
		}
	}

	.text {
		padding: 20rpx;
		display: block;
		font-size: 30rpx !important;
		p{
			font-size: 30rpx !important;
		}
		span{
			font-size: 30rpx !important;
		}
	}

	.title-name {
		padding: 0 20rpx 20rpx 20rpx;
		font-weight: bold;
		font-size: 30rpx;
	}
</style>
